package com.xyy.yueshijia.view;


import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.xyy.yueshijia.R;
import com.xyy.yueshijia.shopping.MyHeadActivity;
import com.xyy.yueshijia.shopping.RegisterActivity;

/**
 * Created by Asus on 2017/2/7.
 */

public class MyFragment extends Fragment implements View.OnClickListener {


    private ImageView mIvHead;

    //  private Button mHeadNamebtn;
//multi-image-selector
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.myfragment, container, false);
        Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);


        //Collapsed  收缩效果设置

        CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout)view.findViewById(R.id.collapsingTooBar);
        collapsingToolbarLayout.setContentScrim(new ColorDrawable(Color.GREEN)); //收缩显示的颜色
        collapsingToolbarLayout.setCollapsedTitleTextColor(Color.BLACK); //收缩文字颜色
        collapsingToolbarLayout.setCollapsedTitleGravity(Gravity.CENTER);
        //collapsingToolbarLayout.setTitle("账户");//文字
        collapsingToolbarLayout.setExpandedTitleGravity(Gravity.BOTTOM);
        //Expanded  展开效果设置
        collapsingToolbarLayout.setExpandedTitleColor(Color.BLUE);

        view.findViewById(R.id.my_relative_food).setOnClickListener(this);

        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        view.findViewById(R.id.my_relative_food).setOnClickListener(this);

        mIvHead = (ImageView) view.findViewById(R.id.my_food_head);

        mIvHead.setOnClickListener(this);

    }


    @Override
    public void onClick(View view) {

        switch (view.getId()) {
            case R.id.my_relative_food:
                Intent intent = new Intent(getActivity(), RegisterActivity.class);
                startActivity(intent);

                //点击头像
            case R.id.my_food_head:
                Intent intent1 =new Intent(getActivity(), MyHeadActivity.class);
                startActivity(intent1);

            default:
                break;

        }
    }



}
